package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;

public class ProgressBarActivity extends AppCompatActivity implements View.OnClickListener {

private Button goneBtn, dlBtn;
private ProgressBar pb, pb1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_progress_bar);
        initUI();
    }

    private void initUI() {
        goneBtn = findViewById(R.id.gone_btn);
        dlBtn = findViewById(R.id.dl_btn);
        pb = findViewById(R.id.pb);
        pb1 = findViewById(R.id.pb1);
        goneBtn.setOnClickListener(this);
        dlBtn.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.gone_btn:
                if(pb1.getVisibility() == View.GONE){
                    pb1.setVisibility(View.VISIBLE);
                } else {
                    pb1.setVisibility(View.GONE);
                }
                break;
            case R.id.dl_btn:
                int progress = pb.getProgress();
                progress+=10;
                pb.setProgress(progress);
                break;
        }
    }
}